package com.example.demo.controller;

import com.example.demo.entity.User;
import com.example.demo.service.SchedualServerHi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Created by wangjialei on 2018/10/10.
 */
@Controller
@Slf4j
public class IndexController {

    @Autowired
    SchedualServerHi schdualServerHi;


    //测试加载页面压力-不使用redis缓存
    @RequestMapping("/view1")
    public String view(Model model){
        //log.info("enter index.");

        List<User> users = schdualServerHi.getAllUser();

        model.addAttribute("users", users);
        model.addAttribute("id", 12345);
        return "index";
    }


    //测试加载页面压力-使用redis缓存
    @RequestMapping("/view2")
    public String viewRedis(Model model){

        List<User> users = schdualServerHi.getAllUserRedis();

        model.addAttribute("users", users);
        model.addAttribute("id", 12345);
        return "index";
    }




}
